const path = require('path');
const devServer = require("./config/devServer.js"); // 代理配置
const V5PcPlugin = require('./config/plugin/V5PcPlugin.js'); // 此处引用了各个功能的webpack插件，来实现统一的功能配置。
const DistInitPlugin = require('./config/plugin/DistInitPlugin.js');
const DistEndPlugin = require('./config/plugin/DistEndPlugin.js');
const FailedPlugin = require('./config/plugin/FailedPlugin.js');
const DonePlugin = require('./config/plugin/DonePlugin.js');
const alias = require('./config/alias.js'); // 别名配置
const version = new Date().getTime();
var options = process.argv;
const ParamsUtils = require('./config/utils/ParamsUtils.js');

const outputPage = require('./config/output');
// console.log(outputPage);

let vueConfig = {
    lintOnSave: false, // eslint关闭
    productionSourceMap: false, // map 映射
    assetsDir: "static",
    baseUrl: "./",
    transpileDependencies: ["./src"],
    configureWebpack: {
        plugins: [

            new DistInitPlugin(), // 插件用法
            new DistEndPlugin(),
            new V5PcPlugin(),
            new DonePlugin(),
            new FailedPlugin(),
        ],
        output: { // js打包后，要保证文件名一致，并且不能有缓存问题
            filename: `static/js/[name].min.js?t=${version}`,
            chunkFilename: `static/js/[name].min.js?t=${version}`
            // chunkFilename: `static/js/chunk-vendors-tree.min.js?t=${version}`
        },
        resolve: {
            alias: alias
        }
    },
    chainWebpack(config) { // css打包后，要保证文件名一致，并且不能有缓存问题
        if (process.env.NODE_ENV === 'production') {
            config.plugins.delete('preload-index');
            config.plugin('extract-css')
                .tap(args => [{
                    filename: `static/css/[name].css?t=${version}`,
                    chunkFilename: `static/css/[name].css?t=${version}`
                }])
        }
    },
    outputDir: ParamsUtils.getOutputDir(),
    devServer: devServer,
    //pages: outputPage,
    pages: {
        'index': 'src/views/task-list/main.js',
        'task-info': 'src/views/task-info/main.js',
        'cs': 'src/views/lookmb/main.js',
    }

};

module.exports = vueConfig;
